﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>匹配字符$的使用</title>
</head>
<body>
    <h3>行尾匹配字符$的使用</h3>
    <script language="JavaScript">
        let reg_expression = /f$/;
        let textString = "microsoft";
        let result = reg_expression.test(textString);  //匹配时返回true,否则false
        document.write("<font size='+1'>" + result + "<br>");
        if (result) {
            document.write("正则表达式/ft$/匹配字符串\"" + textString + "\".<br>");
        }
        else {
            alert("未找到匹配的模式!");
        }
    </script>
</body>
</html>